/**
 * SPDX-FileCopyrightText: 2023-2025 Sangfor Technologies Inc.
 * SPDX-License-Identifier: Mulan PSL v2
 */
<template>
    <div class="resource-progress__wrap">
        <div class="progress-left">
            <div :class="data.icon" class="progress-left-icon"></div>
            <div style="display:inline-block;">
                <p class="title">{{ data.title }}</p>
            </div>
        </div>
        <div class="progress-list">
            <div class="progress-text">
                <span class="unit">已使用{{ data.user }}/{{ (data.total) }}</span>
                <div class="unit use-rate">{{(useRate*100).toFixed(0)}}%</div>
            </div>
            <div class="progress-items">
                <sf-progress-bar :value="useRate" border-radius="10" :text-hidden="true" default-width="100%"/>
            </div>
        </div>
    </div>
</template>

<style lang="less">
.progress-charts-wrap {
    color: #FFF;
    height: 180px;
    display: flex;
    width: 100%;
    justify-content: space-between;
    border-top: none;
}

.progress_charts {
    height: 100%;
    padding: 10px 10px 15px 10px;
    border-radius: 6px;
    background-color: #F7F7F7;
}

.resource-progress__wrap {
    position: relative;

    .progress-left-icon {
        width: 28px;
        height: 24px;
        margin-right: 10px;
        vertical-align: text-bottom;
    }

    .font-important {
        font-weight: bold;
        font-size: 12px;
        color: #FFF;
    }

    .progress-list {
        width: 100%;
        display: flex;
        flex-direction: column;
        .progress-text {
            display: flex;
            justify-content: space-between;
            align-items: flex-end;
            margin-top: 15px;
            padding: 0 16px;
            .unit {
                color: #80848F;
            }
            .use-rate {
                height:24px;
                line-height: 24px;
                color: #7B7B7B;
                font-size: 18px;
                font-weight: 500;
            }
        }

        .progress-items {
            width: 100%;
            display: flex;
            justify-content: center;
            margin-top: 10px;

            .progress {
                margin-left: 25px;
            }
            .sfv-progress-bar {
                width: 100%;
            }
        }

        .user-info {
            float: right;
            text-align: center;
            margin: auto 0 auto 60px;

            .user-info-contain {
                display: inline-block;
                text-align: left;

                .user-info-contain-used, .user-info-contain-surplus {
                    position: relative;

                    &:before {
                        content: '';
                        background: #5F3BFF;
                        width: 6px;
                        height: 6px;
                        border-radius: 50%;
                        position: absolute;
                        left: -18px;
                        top: 6px;
                    }
                }

                .user-info-contain-surplus {
                    &:before {
                        background: #5F3BFF;
                    }
                }

                .user-info-contain-surplus {
                    &:before {
                        background: #CCC;
                    }
                }
            }
        }
    }

    .progress-left {
        display: flex;
        align-items: center;
        position: relative;
        padding: 5px 0 5px 5px;

        .iconcpu {
            background: url("./img/CPU.svg") no-repeat center center;

            &:before {
                content: '';
            }
        }

        .iconxianka {
            background: url("./img/xianka.svg") no-repeat center center;

            &:before {
                content: '';
            }
        }

        .iconneicun1 {
            background: url("./img/neicun.svg") no-repeat center center;

            &:before {
                content: '';
            }
        }

        .icona-24Dcunchu {
            background: url("./img/cunchushebei.svg") no-repeat center center;

            &:before {
                content: '';
            }
        }

        .title {
            font-size: 16px;
            color: #000002;
            font-weight: bold;
            margin: 0;
        }
    }

    .progress {
        width: 25%;
        height: 120px;
        margin-bottom: 20px;
    }
}

@media screen and (max-width: 1380px) {
    .resource-progress__wrap .progress-list .user-info {
        margin-left: 15px;
    }

    .resource-progress__wrap .progress-left .sub-title {
        margin-left: 10px;
    }
}
</style>
<script>

/**
 * .vue
 * @description:
 * @author: zhb
 * @date: 2021/5/8
 */


// 引入基本模板

export default {
    props: {
        data: {
            type: Object, required: true, default: () => ({})
        }
    },
    data() {
        return {
        };
    },
    computed: {
        useRate () {
            if(this.data.total === 0) {
                return  0
            }
            return (this.data.user/this.data.total).toFixed(2)
        }
    },
};
</script>

